﻿<cfsilent>
	<cfscript>
		
		jsonAdvice = getProperty("serviceFactory").getBean("jsonAdvice");
		response = structNew();
		
		subjectId = event.getArg("SubjectID");
		
		transaction {
			
			if ( event.getArg("SubjectName") neq "" AND event.getArg("SubjectShortName") neq "" ) {

				sql = "UPDATE t_subject a 
						SET a.sbj_name = :SubjectName ,
							a.sbj_short = :SubjectShortName ,
							a.sbj_english = :SubjectEnglish 
						WHERE a.sbj_id = :SubjectID ";
				queryObj = new query( datasource=application.dnsMaster );
				queryObj.addParam( name="SubjectName", value= event.getArg("SubjectName") , cfsqltype="cf_sql_varchar" );
				queryObj.addParam( name="SubjectShortName", value=event.getArg("SubjectShortName"), cfsqltype="cf_sql_varchar" );
				queryObj.addParam( name="SubjectEnglish", value=event.getArg("SubjectEnglish"), cfsqltype="cf_sql_varchar" );
				queryObj.addParam( name="SubjectID", value=subjectId, cfsqltype="cf_sql_varchar" );
				queryObj.execute( sql=sql );		
				
			}
			
			sql = "SELECT a.sbj_id,
						   a.sbj_name,
						   a.sbj_short,
						   a.sbj_english
					FROM t_subject a 
					WHERE a.sbj_id = :SubjectID ";
			queryObj = new query( datasource=application.dnsMaster );
			queryObj.addParam( name="SubjectID", value=subjectId, cfsqltype="cf_sql_varchar" );
			rs_subject = queryObj.execute( sql=sql ).getResult();	
			
			structInsert(response, "SubjectID", rs_subject.sbj_id);
			structInsert(response, "SubjectName", rs_subject.sbj_name);
			structInsert(response, "SubjectShortName", rs_subject.sbj_short);
			structInsert(response, "SubjectEnglish", rs_subject.sbj_english);
					
		}

	</cfscript>
</cfsilent><cfoutput>#jsonAdvice.encode(data:response, stringNumbers:true)#</cfoutput>